;---------------------------------------------------------------------
; dkconstanttable.S - table of constants for DK-BASIC - Chris Gerlinsky, 2009
;---------------------------------------------------------------------

.nolist
#include <avr/io.h>	// Include device specific definitions.
.list
#include "dkconstants.h"



;---------------------------------------------------------------------
; FLASH - constants (in code segment)

.section .text

.global dkconstanttable
dkconstanttable:

// AVR register definitions (based on mega644p)
.string "porta"
.word	PORTA
.string "ddra"
.word	DDRA
.string "pina"
.word	PINA
.string "portb"
.word	PORTB
.string "ddrb"
.word	DDRB
.string "pinb"
.word	PINB
.string "portc"
.word	PORTC
.string "ddrc"
.word	DDRC
.string "pinc"
.word	PINC
.string "portd"
.word	PORTD
.string "ddrd"
.word	DDRD
.string "pind"
.word	PIND

.string "gtccr"
.word	GTCCR
.string "tccr0a"
.word	TCCR0A
.string "tccr0b"
.word	TCCR0B
.string "tcnt0"
.word	TCNT0
.string "ocr0a"
.word	OCR0A
.string "ocr0b"
.word	OCR0B
.string "gpior1"
.word	GPIOR1
.string "gpior2"
.word	GPIOR2
.string "spcr"
.word	SPCR
.string "spsr"
.word	SPSR
.string "spdr"
.word	SPDR
.string "acsr"
.word	ACSR
.string "mondr"
.word	MONDR
.string "ocdr"
.word	OCDR
.string "smcr"
.word	SMCR
.string "mcusr"
.word	MCUSR
.string "mcucr"
.word	MCUCR
.string "spmcsr"
.word	SPMCSR
.string "adcl"
.word	ADCL
.string "adch"
.word	ADCH
.string "adcsra"
.word	ADCSRA
; bit definitions for ADCSRA
.string "aden"
.word	7
.string "adsc"
.word	6
.string "adps2"
.word	2
.string "adps1"
.word	1
.string "adps0"
.word	0

.string "adcsrb"
.word	ADCSRB

.string "admux"
.word	ADMUX
; bit definitions for ADMUX
.string "adlar"
.word	5

.string "didr0"
.word	DIDR0
.string "didr1"
.word	DIDR1
.string "tccr1a"
.word	TCCR1A
.string "tccr1b"
.word	TCCR1B
.string "tccr1c"
.word	TCCR1C
.string "tcnt1l"
.word	TCNT1L
.string "tcnt1h"
.word	TCNT1H
.string "icr1l"
.word	ICR1L
.string "icr1h"
.word	ICR1H
.string "ocr1al"
.word	OCR1AL
.string "ocr1ah"
.word	OCR1AH
.string "ocr1bl"
.word	OCR1BL
.string "ocr1bh"
.word	OCR1BH


.byte	0								; end table with an empty string (NULL)


.align 2								; code must be aligned on word boundary


;---------------------------------------------------------------------
; FLASH - code

;---------------------------------------------------------------------
; dkfindconstant
; r25:r24 in = ptr to string in ram
; r25:r24 out = int value
; note: side effect: string is converted to lowercase

.func dkfindconstant
.global dkfindconstant
dkfindconstant:
	ldi		r23, hi8(dkconstanttable)	; dkconstanttable in FLASH is a list of names and matching constant values
	ldi		r22, lo8(dkconstanttable)

	call	dksearchtable

	ret
.endfunc


;---------------------------------------------------------------------

